package com.leapp.sk.viewdelegate.adapter.personal

import android.content.Context
import android.widget.ImageView
import android.widget.LinearLayout
import cc.vv.lkbasecomponent.util.LKScreenUtil
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.request.RequestOptions
import com.example.mvp.delegate.BaseAdapterDelegate
import com.leapp.sk.R

/**
 * 意见反馈详情图片适配器视图托管类
 * @author  chaohaipeng  on 2018/8/9.
 */
class FeedBackDetialImageAdapterDelegate : BaseAdapterDelegate(){
    /**
     * 图片加载操作
     */
    var mRequestOptions: RequestOptions = RequestOptions()
    override fun getOptionsMenuId(): Int {
        return 0
    }

    override fun initWidget() {
    }

    override fun onDestroy() {
    }

    override fun initLayoutRes(): Int {
        return R.layout.adapter_feed_back_detial_image
    }

    /**
     * 初始化数据
     */
    fun initData(context:Context,imagePath:String){
        val iv_afbdi_image = getView<ImageView>(R.id.iv_afbdi_image)
        val layoutParams:LinearLayout.LayoutParams = iv_afbdi_image.layoutParams as LinearLayout.LayoutParams
        layoutParams.width=(LKScreenUtil.getScreenWidth()-LKScreenUtil.dp2px(15f))/2
        layoutParams.height=(LKScreenUtil.getScreenWidth()-LKScreenUtil.dp2px(15f))
        iv_afbdi_image.layoutParams=layoutParams
        setImage(context,imagePath ,iv_afbdi_image)
    }


private fun setImage(context:Context,imagePath:String ,imageView:ImageView){
    val mRequestManager = Glide.with(context)
    mRequestOptions.diskCacheStrategy(DiskCacheStrategy.NONE)
    mRequestOptions.skipMemoryCache(true)
    mRequestOptions.error(R.mipmap.icon_test_feed)
    mRequestManager?.load(imagePath)
            ?.thumbnail(0.2f)
            ?.apply(mRequestOptions)
            ?.into(imageView)
    imageView.setTag(R.id.tag_image,imagePath)


}


}